#!/bin/bash

CRED='\E[0;31m'
CGREEN='\E[0;32m'
CYELLOW='\E[0;33m'
CBLUE='\E[0;34m'
CPINK='\E[0;35m'
CCYAN='\E[0;36m'
CEND='\E[0m'

function msg(){
    color=$1

    # 如果参数大于2个
    if [ ${#@} -gt 2 ]; then
        for((i=3;i<=$#;i++)); do
            j=${!i}
            output="${output} $j"
        done
        output=${output}
    else
        output=$2
    fi

    case "$color" in
        red|RED)
            echo -e "${CRED}$output${CEND}"
            ;;
        green|GREEN)
            echo -e "${CGREEN}$output${CEND}"
            ;;
        yellow|YELLOW)
            echo -e "${CYELLOW}$output${CEND}"
            ;;
        blue|BLUE)
            echo -e "${CBLUE}$output${CEND}"
            ;;
        pink|PINK)
            echo -e "${CPINK}$output${CEND}"
            ;;
        cyan|CYAN)
            echo -e "${CCYAN}$output${CEND}"
            ;;
        *)
            echo "Usage $0 {red|green|yellow|blue|pink|cyan}" content
            exit
    esac
}
